package com.yun.service;

import com.yun.dao.AdminDao;
import com.yun.pojo.Admin;
import com.yun.pojo.User;
import com.yun.utils.AdminUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class AdminService {
	 @Autowired
	 private AdminDao admindao;
	
	 public List<User> selectAll(){
	      List<User> userlist=new ArrayList<User>();
	      userlist=admindao.selectAll();
	      return userlist;
	 }
	 public Admin findAdmin(Admin admin) {
         admin.setPassword(AdminUtils.MD5(admin.getPassword()));
         try {
             Admin exsitadmin = admindao.findAdmin(admin);
             return exsitadmin;
         } catch (Exception e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
             return null;
         }
     }

    public int deleteUser(String name) {
        return admindao.deleteUser(name);
    }

    public User getAdminByName(String name) {
        User user = admindao.getAdminByName(name);
        return user;
    }
}
